<template>
	<div>
		<!-- <div class="smp-search smp_panel">
			
			<div class="smp_panel_header" >
				<div class="smp_panel_pre"></div>
				<div class="smp_panel_title">待办任务</div>
				<div class="smp-panel_option">
					<el-button size="mini" type="primary"  plain  @click="onSubmit">
						<i class="el-icon-refresh"></i>
						刷&nbsp;新</el-button>
				</div>
			</div>
		<div class="smp_panel_body" > -->
		<smpPanel title="待办任务">
			<el-button slot="option" size="mini" type="primary"  plain  @click="onSubmit">
				<i class="el-icon-refresh"></i>
				刷&nbsp;新</el-button>
			
	
			<el-table :data="list" size="mini" stripe  style="width: 100%">
				<!-- <el-table-column prop="taskId" label="任务ID" width="200" align="center">
				</el-table-column>
				 -->
				
			<!-- 	<el-table-column prop="taskId" label="任务编号" width="100">
				</el-table-column> -->
				<el-table-column prop="sid" label="工单编号" width="150" align="center">
				</el-table-column>
				<el-table-column prop="qmsNo" label="需求编号" width="220" align="center">
				</el-table-column>
				<el-table-column prop="qmsName" label="需求名称" align="center" show-overflow-tooltip>
				</el-table-column>

				<el-table-column prop="applyDate" label="申请时间" width="150" align="center">
				</el-table-column>

				<el-table-column prop="applyUser" label="申请人" width="100" align="center">
					<template slot-scope="scope">
						<userCard :user="$store.getters.getUser(scope.row.applyUser)"></userCard>	
					</template>
				</el-table-column>
				<el-table-column prop="applyType" label="工单类型" width="100" align="center">
					 <template slot-scope="scope">
						{{scope.row.applyType|dictName("SMP0009")}}
					</template> 
				</el-table-column>
				<el-table-column prop="taskName" label="任务类型" width="130" align="center">
				</el-table-column>
				
				<el-table-column prop="createDate" label="任务开始时间" width="150" align="center">
				</el-table-column>	
					<el-table-column prop="assignee" label="处理人"  show-overflow-tooltip align="center">
						<template slot-scope="scope">
							<template v-if="scope.row.assignee">
								<userCard :user="$store.getters.getUser(scope.row.assignee)"></userCard>	
							</template>
							<template v-if="!scope.row.assignee">
									<template v-for="(item,index) in scope.row.adminUsers">
										<span v-if="index>0" > , </span>
										<userCard :user="$store.getters.getUser(item)" style="display:inline-block"></userCard>	
										
									</template>
							</template>
						
						</template>
					</el-table-column>

				<el-table-column label="操作" align="center" width="100" >
					<template slot-scope="scope">
				         <el-link 
						 type="primary"
						 :underline="false"
						 style="font-size: 12px;"
				         @click="handleEdit(scope.$index, scope.row)">任务处理</el-link>
					</template>
				</el-table-column>
			</el-table>
			<div class="smp-pagination">
				<el-pagination background size="medium" layout="total,sizes,prev, pager, next,jumper" :page-size="query.pageSize" :page-sizes="[5,10,15,20]" :total="total" :current-page="query.pageNum" @current-change = "currentChange" @size-change="sizeChange">
				</el-pagination>
			
			</div>
				</smpPanel>
	</div>
</template>

<script>
	"use strict";
	import {
		myTask
	} from '@/api/process.js';

	export default {
		data() {
			return {

				list: [],
				query: {
					body: {
						roleName: "",
						id: ""
					},
					pageNum: 1,
					pageSize: 5
				},
				total: 0,

				form: {
					requireNo: '',
					applyUser: '',
					applyDate: '',
					status: ''
				},
				dialogVisible: false,
				options: [],
				requireNooptions: [],
				activeIndex: '1',
				activeIndex2: '1',
			};



		},


		created() {
			
			this.getList();
		},
		methods: {
			handleSelect(key, keyPath) {
				console.log(key, keyPath);
			},

			onSubmit() {
				this.getList();
			},

			handleClick() {
				this.dialogVisible = true;
			},

            /**
			 * 跳转到审批页面
			 * @param {Object} index
			 * @param {Object} row
			 * 
			 */
			handleEdit(index, row) {
				
				let obj ={};
				Object.assign(obj,row);
				if(row.taskkey=='Examine'){
					this.$router.push({name:'processExamine',query:obj})
				}else if(row.taskkey=='AcceptDemand'){
					this.$router.push({name:'processAccept',query:obj})
				}else if(row.taskkey=='Reassignment'){
					this.$router.push({name:'processReassignment',query:obj})
				}else if(row.taskkey=='DevelopmentConfirm'){
					this.$router.push({name:'processDevelop',query:obj})
				}else if(row.taskkey=='demandApplication'){	//工单申请跳转到申请页面
					this.$router.push({name: 'demandApplication',query:obj})
				}else  if(row.taskkey=='ServerSystemExamine'){	//工单申请跳转到申请页面
					this.$router.push({name: 'processServerSystemExamine',query:obj})
				}else  if(row.taskkey=='EnvAdminExamine'){	//测试管理员审批
					this.$router.push({name: 'processEnvAdminExamine',query:obj})
				}
				
				
				
			},

			getUserList(query) {

			},

			getrequireList(query) {},

			getList() {
				myTask(this.query).then(response => {
					this.list = response.data.extend.list
					this.total = response.data.extend.total;

				}).catch(error => {
					console.info("失败");
					console.info(error.message);
				});
			},
			
			currentChange(val){
				this.query.pageNum = val;
				this.getList();
			},
			sizeChange(val){
				this.query.pageSize = val;
				this.query.pageNum = 1;
				this.getList();
			},
		},
	}
</script>

<style>
</style>
